<script setup lang='ts'>
import { useRouter } from 'vue-router';
import { useCounterStore } from '@/stores/users';
import { Dialog } from 'vant';
const router = useRouter();
const userStore = useCounterStore();
// TODO 退出功能
const logout = () => {
    Dialog.confirm({
        title: '您确定要退出登录吗?', beforeClose,
    });
    /* 
        清除userid,token
        清除storage里面的userid,token
        跳转到login页面
    */
}
//是否确认退出
const beforeClose = (action:any) => {
    if (action === 'confirm') {
        userStore.logoutHandler();
        router.push("/login")
    }
    Dialog.close();
}

</script>
<template>

    <div class="center">
        <van-nav-bar title="个人中心" left-text="返回" right-text="退出" left-arrow @click-left="$router.back()"
            @click-right="logout" />
        <van-cell-group title="个人中心">
            <van-cell title="地址管理" is-link url="/address" />
            <van-cell title="订单中心" is-link url="/order" />
        </van-cell-group>
    </div>
</template>
<style scoped lang='scss'>

</style>